<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>promise</title>
</head>
<body>
    <script type="text/javascript">
        // 03.html中的情况就是回调地狱，因此出现了promise
        // promise的出现很好的解决了回调地狱的问题
        new Promise((resolve, reject) => {
            setTimeout(() => {
                resolve('OK')
            }, 1000)
        })
        .then(r => {
            console.log('success: ' + r)
        })
        .catch(e => {
            console.log('err: ' + e)
        })
       
    </script>
</body>
</html>